<style src="./index.scss" lang="scss" scoped rel="stylesheet/scss"></style>
<template src="./index.html"></template>
<script>
export default {
  mixins: [Vue.prototype.$vFN.Mixins.Base],
  computed: {},
  data() {
    return {
      item: null,
      title: "【同意】售后申请",
      form: {
        // 地址库id
        addressId: null,
      },
      // 窗口显示
      boxVisible: false,
      // 地址库
      addressOptions: [],
    };
  },
  methods: {
    // 验证
    validate() {
      return new Promise((resolve, reject) => {
        this.$refs["editForm"].validate((valid) => {
          valid ? resolve(true) : resolve(false);
        });
      });
    },
    // 提交
    async submit() {
      console.log("1");
      if (!(await this.validate())) {
        return;
      }
      console.log("2");
      let _data = await this.$vFN.Http.post(
        {
          url: "mall-site-portal/order-rights/agreeOrderRights",
          data: {
            addressId: this.form.addressId,
            orderRightsId: this.item.id,
          },
        },
        window
      );
      if (_data._ok) {
        this.$vFN.Tools.messageSuccess("操作成功");
        this.editBoxClose();
        this.onSuccess();
      }
    },
    // 成功回调
    onSuccess() {},
    // 取消回调
    onCancel() {},
    // 失败回调
    onError() {},
    // 关闭窗口
    editBoxClose() {
      this.boxVisible = false;
    },
    // 取消
    editBoxCancel() {
      this.editBoxClose();
    },

    show(e, item) {
      console.log(e, item);
    },
  },
  watch: {},
  async mounted() {
    // 数据源 地址库
    this.addressOptions = await this.$vFN.Tools.getSelectListSource(
      {
        url: "mall-site-portal/order-rights/getAddress",
        format: false,
      },
      window
    );

    this.boxVisible = true;
  },
  beforeCreate() {},
};
</script>